Data loading

suppressPackageStartupMessages({
  library(SummarizedExperiment)
  library(SEtools)
  library(edgeR)
  library(DT)
  library(pheatmap)
  library(plotly)
  library(dplyr)
  library(sva)
  library(viper)
})
source("Functions/EDC_Functions.R")
source("Functions/CriFormatted.R")
load("Data/AllSEcorrected.RData",verbose=T)
## Loading objects:
##   SEs
##   DEAs
load("Data/regulon_weighted.RData", verbose = T)
## Loading objects:
##   regulon

psychencode network

Fetal chronic

se <- SEs$chronic.fetal
se <- SEtools::log2FC(se, "corrected", controls=se$EXPO=="CNT", isLog = TRUE)
ag <- readRDS("Data/psychencode_reduced.rds")
ag <- ag[which(ag[,1] %in% row.names(se) & ag[,2] %in% row.names(se)),]
write.table( ag, file="Data/psychencode_reduced.txt", col.names=F, row.names=F, sep="\t", quote=F)
tf1.ch <- TFA(se, DEAs$chronic.fetal, ~EXPO, "Data/psychencode_reduced.txt",
              testCoef=c("EXPO1X","EXPO1000X"), assayName="corrected")
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000
tf1.ch <- SEtools::log2FC(tf1.ch, "viper", tf1.ch$EXPO=="CNT", isLog=TRUE)
plotTFA(tf1.ch)
## Warning: `line.width` does not currently support multiple values.

We restrict ourselves to transcription factors whose expression pattern is coherent with their differential activity:

rd <- rowData(tf1.ch)
sig <- row.names(rd)[(sign(rd$activity.max.logFC)==sign(rd$expression.logFC) & rd$activity.FDR<0.05 & rd$expression.FDR<0.1)]
sef <- se
m <- mergeSEs(list(expression=se,activity=tf1.ch), do.scale = FALSE)
m$assay <- m$Dataset
sehm(m[,which(m$EXPO %in% c("CNT","1X","1000X"))], sig, do.scale = FALSE, assayName = "log2FC", anno_columns = c("EXPO2","assay"), breaks = 0.99, main="Expression and activity of significant TFs")

FetTF <- sig

Organoids chronic

se <- SEs$chronic.org
se <- SEtools::log2FC(se, "corrected", controls=se$EXPO=="CNT", isLog = TRUE)
ag <- readRDS("Data/psychencode_reduced.rds")
ag <- ag[which(ag[,1] %in% row.names(se) & ag[,2] %in% row.names(se)),]
write.table( ag, file="Data/psychencode_reduced.txt", col.names=F, row.names=F, sep="\t", quote=F)
to1.ch <- TFA(se, DEAs$chronic.org, ~EXPO, "Data/psychencode_reduced.txt",
              testCoef=c("EXPO1X","EXPO1000X"), assayName="corrected")
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## number of iterations= 338
to1.ch <- SEtools::log2FC(to1.ch, "viper", to1.ch$EXPO=="CNT", isLog=TRUE)
plotTFA(to1.ch)
## Warning: `line.width` does not currently support multiple values.

We restrict ourselves to transcription factors whose expression pattern is coherent with their differential activity:

rd <- rowData(to1.ch)
sig <- row.names(rd)[(sign(rd$activity.max.logFC)==sign(rd$expression.logFC) & rd$activity.FDR<0.05 & rd$expression.FDR<0.05)]
m <- mergeSEs(list(expression=se,activity=to1.ch), do.scale = FALSE)
m$assay <- m$Dataset
sehm(m[,which(m$EXPO %in% c("CNT","1X","1000X"))], sig, do.scale = FALSE, assayName = "log2FC", anno_columns = c("EXPO2","assay"), breaks = 0.99, main="Expression and activity of significant TFs",show_rownames = T)

OrgTF <-sig
TF <- union(OrgTF,FetTF) 

Merge

rd <- merge(rowData(to1.ch), rowData(tf1.ch), by="row.names", suffixes=c("organoid","fetal"))
sig <- rd$Row.names[which(
  apply(sign(as.matrix(rd[,grep("logFC",colnames(rd))])),1,FUN=function(x) length(unique(x))==1) &
  rd$activity.FDRorganoid < 0.1 & rd$activity.FDRfetal < 0.2 &
    rd$expression.FDRorganoid < 0.25 & rd$expression.FDRfetal < 0.25
)]
m <- mergeSEs(list(exp.org=se,activity.org=to1.ch,exp.fetal=sef, activity.fetal=tf1.ch), do.scale = FALSE)
m$assay <- c("expression","activity")[1+as.numeric(grepl("activity",m$Dataset))]
m$system <- c("fetal","organoid")[1+as.numeric(grepl("org",m$Dataset))]
sehm(m[,which(m$EXPO %in% c("CNT","1X","1000X"))], sig, do.scale = FALSE, assayName = "log2FC", anno_columns = c("EXPO2","assay","system"), breaks = 0.99, main="Expression and activity of significant TFs in both fetal and organoids", sortRowsOn = NULL)

TFshort<-sig
save(OrgTF,FetTF,TF, TFshort, file = "Data/HormonalGenes/HormonalTFs/TF.RData")
Org <- to1.ch
Fet <- tf1.ch
save(Org, Fet, file="Data/TFA.RData")

Authors

Nicolò Caporale: ,

Cristina Cheroni:

Pierre-Luc Germain:

Giuseppe Testa:

Lab: http://www.testalab.eu/

‘Date: February 19, 2021’

sessionInfo()
## R version 4.0.3 (2020-10-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.7
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] viper_1.24.0                sva_3.38.0                 
##  [3] BiocParallel_1.24.1         genefilter_1.72.1          
##  [5] mgcv_1.8-34                 nlme_3.1-152               
##  [7] dplyr_1.0.4                 plotly_4.9.3               
##  [9] ggplot2_3.3.3               pheatmap_1.0.12            
## [11] DT_0.17                     edgeR_3.32.1               
## [13] limma_3.46.0                SEtools_1.4.0              
## [15] SummarizedExperiment_1.20.0 Biobase_2.50.0             
## [17] GenomicRanges_1.42.0        GenomeInfoDb_1.26.2        
## [19] IRanges_2.24.1              S4Vectors_0.28.1           
## [21] BiocGenerics_0.36.0         MatrixGenerics_1.2.1       
## [23] matrixStats_0.58.0         
## 
## loaded via a namespace (and not attached):
##  [1] Rtsne_0.15             colorspace_2.0-0       rjson_0.2.20          
##  [4] ellipsis_0.3.1         class_7.3-18           circlize_0.4.12       
##  [7] XVector_0.30.0         GlobalOptions_0.1.2    clue_0.3-58           
## [10] farver_2.0.3           bit64_4.0.5            AnnotationDbi_1.52.0  
## [13] codetools_0.2-18       splines_4.0.3          cachem_1.0.4          
## [16] knitr_1.31             jsonlite_1.7.2         Cairo_1.5-12.2        
## [19] annotate_1.68.0        kernlab_0.9-29         cluster_2.1.1         
## [22] png_0.1-7              compiler_4.0.3         httr_1.4.2            
## [25] assertthat_0.2.1       Matrix_1.3-2           fastmap_1.1.0         
## [28] lazyeval_0.2.2         htmltools_0.5.1.1      tools_4.0.3           
## [31] gtable_0.3.0           glue_1.4.2             GenomeInfoDbData_1.2.4
## [34] V8_3.4.0               Rcpp_1.0.6             vctrs_0.3.6           
## [37] crosstalk_1.1.1        iterators_1.0.13       xfun_0.21             
## [40] stringr_1.4.0          openxlsx_4.2.3         lifecycle_1.0.0       
## [43] XML_3.99-0.5           MASS_7.3-53.1          zlibbioc_1.36.0       
## [46] scales_1.1.1           TSP_1.1-10             RColorBrewer_1.1-2    
## [49] ComplexHeatmap_2.6.2   yaml_2.2.1             curl_4.3              
## [52] memoise_2.0.0          segmented_1.3-2        stringi_1.5.3         
## [55] RSQLite_2.2.3          highr_0.8              randomcoloR_1.1.0.1   
## [58] foreach_1.5.1          e1071_1.7-4            seriation_1.2-9       
## [61] zip_2.1.1              shape_1.4.5            rlang_0.4.10          
## [64] pkgconfig_2.0.3        bitops_1.0-6           evaluate_0.14         
## [67] lattice_0.20-41        purrr_0.3.4            htmlwidgets_1.5.3     
## [70] bit_4.0.4              tidyselect_1.1.0       magrittr_2.0.1        
## [73] R6_2.5.0               generics_0.1.0         DelayedArray_0.16.1   
## [76] DBI_1.1.1              pillar_1.4.7           withr_2.4.1           
## [79] mixtools_1.2.0         survival_3.2-7         RCurl_1.98-1.2        
## [82] tibble_3.0.6           crayon_1.4.1           KernSmooth_2.23-18    
## [85] rmarkdown_2.6          GetoptLong_1.0.5       locfit_1.5-9.4        
## [88] grid_4.0.3             data.table_1.13.6      blob_1.2.1            
## [91] digest_0.6.27          xtable_1.8-4           tidyr_1.1.2           
## [94] munsell_0.5.0          registry_0.5-1         viridisLite_0.3.0